﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DemoJCodeGen
{
    public static class CodeGenUtil
    {
        private static bool IsIndentChar(string c)
        {
            string[] indentChars = { " ", "  " };

            foreach (string indentChar in indentChars)
            {
                if (c.Equals(indentChar))
                {
                    return true;
                }
            }

            return false;
        }

        public static string GetPrefixIndent(string line)
        {
            string prefixIndent = string.Empty;

            for(int i=0; i<line.Length; i++)
            {
                string c = line.Substring(i, 1);

                if (IsIndentChar(c))
                    prefixIndent += c;
                else
                    return prefixIndent;
            }

            return string.Empty;
        }


    } // end of CodeGenUtil
}
